package host.springboot.framework.mybatisplus.validation.annotation;

import host.springboot.framework.mybatisplus.validation.DatabaseExistsByIdValidator;
import host.springboot.framework.mybatisplus.service.BaseService;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 数据库是否存在校验
 *
 * @author JiYinchuan
 * @since 1.0.0
 */
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = DatabaseExistsByIdValidator.class)
public @interface DatabaseExistsById {

    Class<? extends BaseService<?>> repository();

    String message() default "数据不存在";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
